<template>
  <div class="hello">
    <van-nav-bar
  title="编辑信息"
  left-text="返回"
  left-arrow
  @click-left="onClickLeft"

/>


  <van-form @submit="onSubmit">
  <van-field
    v-model="username"
    name="用户名"
    label="用户名"
    placeholder="用户名"

  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"

  />
  <van-field
    v-model="phone"
    type="phone"
    name="手机号"
    label="手机号"
    placeholder="手机号"
  />
  <van-field
    v-model="gender"
    type="gender"
    name="性别"
    label="性别"
    placeholder="性别"
  />
  <van-field
    v-model="age"
    type="age"
    name="年龄"
    label="年龄"
    placeholder="年龄"
  />

  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit">提交</van-button>
  </div>
</van-form>
  </div>
</template>

<script>
import url from "../tools/url"
export default {
  name: 'Edit',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      id:"",
      username:"",
      password:"",
      gender:"",
      age:"",
      phone:""
    }
  },
  methods: {
     onClickLeft(){
       this.$router.go(-1)
     },
     onSubmit(){
       var token = sessionStorage.getItem("token");
       console.log(this.id,token)
        var  str =`id=${this.id}&token=${token}&phone=${this.phone}&name=${this.username}&gender=${this.gender}&age=${this.age}&password=${this.password}`;
      this.axios.post(url.UPDATE,str)
      .then(res=>{
        console.log(res)
      })
     }
  },
  mounted(){
       this.id = this.$route.query.id;
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
